package com.toommi.refuse.common.enums;

/**
 * ..
 * 普通垃圾分类类型
 *
 * @author yangg
 * @since 2019-08-01 09:49
 */
public enum NormalTrashTypeEnum {

    /**
     * 厨余垃圾
     */

    KITCHEN(1, "kitchen", "厨余垃圾"),

    TOXIC(2, "toxic", "有毒垃圾"),

    OTHER(3, "other", "其他垃圾");

    private long id;

    public long getId() {
        return id;
    }

    NormalTrashTypeEnum(long id, String code, String note) {
        this.id = id;
        this.code = code;
        this.note = note;
    }

    private String code;

    private String note;

    public String getCode() {
        return code;
    }

    public String getNote() {
        return note;
    }

    NormalTrashTypeEnum(String code, String note) {
        this.code = code;
        this.note = note;
    }

    /**
     * 校验值是否存在枚举范围内
     *
     * @param id 被校验值
     * @return 是否存在
     */
    public static boolean hasValue(long id) {
        for (NormalTrashTypeEnum typeEnum : NormalTrashTypeEnum.values()) {
            if (typeEnum.getId() == id) {
                return true;
            }
        }
        return false;
    }

    public static NormalTrashTypeEnum getTypeById(long id) {
        for (NormalTrashTypeEnum typeEnum : NormalTrashTypeEnum.values()) {
            if (typeEnum.getId() == id) {
                return typeEnum;
            }
        }
        return null;
    }

}
